import { LabMap } from "@/module/labMap"
import { isInArray } from "@/utils"

// 化合物合成顺序 映射
export const ResourceMapData:{source:ResourceConstant,dis:ResourceConstant,map:ResourceConstant[]}[] = [
    /*  */
    {source:'ZK',dis:'G',map:[]},
    {source:'ZK',dis:'GH2O',map:['G','GH',]},
    {source:'ZK',dis:'GHO2',map:['G','GO']},
    {source:'ZK',dis:'XGH2O',map:['G','GH','GH2O']},    
    {source:'ZK',dis:'XGHO2',map:['G','GO','GHO2']},
    {source:'G',dis:'GH2O',map:['GH2O']},
    {source:'G',dis:'XGH2O',map:['GH2O','GH']},
    {source:'G',dis:'GHO2',map:['GHO2']},
    {source:'G',dis:'XGHO2',map:['GHO2','GO']},
    {source:'GO',dis:'GHO2',map:[]},
    {source:'GO',dis:'XGHO2',map:['GHO2']},
    {source:'GH',dis:'GH2O',map:[]},
    {source:'GH',dis:'XGH2O',map:['GH2O']},
    {source:'GHO2',dis:'XGHO2',map:[]},
    {source:'GH2O',dis:'XGH2O',map:[]},
    {source:'UL',dis:'G',map:[]},
    {source:'UL',dis:'GH2O',map:['G','GH',]},
    {source:'UL',dis:'GHO2',map:['G','GO',]},
    {source:'UL',dis:'XGH2O',map:['G','GH','GH2O']},
    {source:'UL',dis:'XGHO2',map:['G','GO','GHO2']},
    {source:'UH',dis:'UH2O',map:[]},
    {source:'UH',dis:'XUH2O',map:['UH2O',]},
    {source:'UH2O',dis:'XUH2O',map:[]},    
    {source:'UO',dis:'UHO2',map:[]},
    {source:'UO',dis:'XUHO2',map:['UHO2',]},
    {source:'UHO2',dis:'XUHO2',map:[]},
    {source:'KH',dis:'KH2O',map:[]},
    {source:'KH',dis:'XKH2O',map:['KH2O']},
    {source:'KH2O',dis:'XKH2O',map:[]},
    {source:'KO',dis:'KHO2',map:[]},
    {source:'KO',dis:'XKHO2',map:['KHO2',]},
    {source:'KHO2',dis:'XKHO2',map:[]},
    {source:'LH',dis:'LH2O',map:[]},
    {source:'LH',dis:'XLH2O',map:['LH2O']},
    {source:'LH2O',dis:'XLH2O',map:[]},
    {source:'LO',dis:'LHO2',map:[]},
    {source:'LO',dis:'XLHO2',map:['LHO2']},
    {source:'LHO2',dis:'XLHO2',map:[]},
    {source:'ZH',dis:'ZH2O',map:[]},
    {source:'ZH',dis:'XZH2O',map:['ZH2O']},
    {source:'ZH2O',dis:'XZH2O',map:[]},
    {source:'ZO',dis:'ZHO2',map:[]},
    {source:'ZO',dis:'XZHO2',map:['ZHO2']},
    {source:'ZHO2',dis:'XZHO2',map:[]},
    {source:'OH',dis:'GH2O',map:[]},
    {source:'OH',dis:'GHO2',map:[]},
    {source:'OH',dis:'XGH2O',map:['GH2O']},
    {source:'OH',dis:'XGHO2',map:['GHO2']},
    {source:'OH',dis:'UH2O',map:[]},
    {source:'OH',dis:'XUH2O',map:['UH2O']},
    {source:'OH',dis:'UHO2',map:[]},
    {source:'OH',dis:'XUHO2',map:['UHO2']},
    {source:'OH',dis:'LH2O',map:[]},
    {source:'OH',dis:'XLH2O',map:['LH2O']},
    {source:'OH',dis:'LHO2',map:[]},
    {source:'OH',dis:'XLHO2',map:['LHO2']},
    {source:'OH',dis:'KH2O',map:[]},
    {source:'OH',dis:'XKH2O',map:['KH2O']},
    {source:'OH',dis:'KHO2',map:[]},
    {source:'OH',dis:'XKHO2',map:['KHO2']},
    {source:'OH',dis:'ZH2O',map:[]},
    {source:'OH',dis:'XZH2O',map:['ZH2O']},
    {source:'OH',dis:'ZHO2',map:[]},
    {source:'OH',dis:'XZHO2',map:['ZHO2']},
]

/* 判断目标资源的上级资源是否已经达到要求 */
export function resourceMap(rType:ResourceConstant,disType:ResourceConstant):ResourceConstant[]{
    if (isInArray(['XGH2O','XGHO2','XLH2O','XLHO2','XUH2O','XUHO2','XKH2O','XKHO2','XZH2O','XZHO2'],rType)){console.log("是",rType,' 返回空列表');return []}
    for (var i of ResourceMapData)
    {
        if (i.source == rType && i.dis == disType)
        {
            return i.map as ResourceConstant[]
        }
    }
    console.log("resourceMap返回了空列表")
    return []
}

/* 根据子资源寻找合成资源 */
export function reverseLabMap(raw1:ResourceConstant,raw2:ResourceConstant):ResourceConstant{
    var typeList = [raw1,raw2]
    for (var i in LabMap)
    {
        if (isInArray(typeList,LabMap[i].raw1) && isInArray(typeList,LabMap[i].raw2))
        return i as ResourceConstant
    }
    return null
}